<?php

namespace app\admin\model\notice;

use think\Model;
use traits\model\SoftDelete;

class Noticesendrecode extends Model
{
    use SoftDelete;



    // 表名
    protected $name = 'notice_sendrecode';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    public function base($query)
    {
        $query->alias('noticesendrecode')->where('noticesendrecode.caijiakuid',CAIJIAKU_ID)->useSoftDelete($this->deleteTime);
    }
    public static function init()
    {
        self::beforeInsert(function ($row) {
            $row->caijiakuid = CAIJIAKU_ID;
        });
    }


    public function getVisibleSwitchList()
    {
        return ['0' => __('关闭'), '1' => __('启用')];
    }

    public function getTypeList()
    {
        return ['msg' => __('站内推送'), 'email' => __('邮箱'), 'mptemplate' => '模版消息(公众号)'];
    }

    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

}